#include "stdio.h"

double Lcd_Pow(double x,int y)
{
	int i = 0;
	double Result = 1;
	for(i=0;i<y;i++)
	{
		Result = Result *x;
	}
	return Result;
}

void handleData(char *Data)
{
	int i = 0,numData = 0,numOp = 0,fix = 0,firstCount = 0,decimalsFlag = 0;
	int powNum = 1;
	int mod1 = 0, mod2 = 0;
	double tempData[8]={0};
	double sum = 0;
	double decimals = 0;
	char op[8]={0};
	while(Data[i] != 0)
	{
		if((Data[i] >= '0') && (Data[i] <= '9'))
		{
			if(decimalsFlag == 0){
				tempData[numData] = (tempData[numData] * 10) + (Data[i] - '0');
			}
			else{
				decimals = decimals + ((Data[i] - '0') * Lcd_Pow(0.1,powNum));
				powNum++;
			}	
		}
		else if(Data[i] == '.')
		{
			decimalsFlag = 1; 
		}
		else
		{
			if(decimalsFlag == 1){
				tempData[numData] = tempData[numData] + decimals;
			}
			op[numOp] = Data[i];
			numData++;
			numOp++;
			decimalsFlag = 0;
			decimals = 0;
			powNum = 1;
		}
		i++;
	}
	printf("%.2f\r\n",tempData[0]); 
	printf("%.2f\r\n",tempData[1]); 
	printf("%.2f\r\n",tempData[2]); 
		
	i = 0;
	while(op[i] != 0)
	{
		if((op[i] == '*') && ((op[i+1] == '+') || (op[i+1] == '-')))
		{
			if((op[i-1] == '*')||(op[i-1] == '/')||(op[i-1] == '%')){
				tempData[fix] = tempData[fix] * tempData[i+1];
			}
			else{
				tempData[i] = tempData[i] * tempData[i+1];
			} 
		}
		else if((op[i] == '/') && ((op[i+1] == '+') || (op[i+1] == '-')))
		{
			if((op[i-1] == '*')||(op[i-1] == '/')||(op[i-1] == '%')){
				tempData[fix] = tempData[fix] / tempData[i+1];
			}
			else{
				tempData[i] = tempData[i] / tempData[i+1];
			}
		}
		else if((op[i] == '%') && ((op[i+1] == '+') || (op[i+1] == '-')))
		{
			if((op[i-1] == '*')||(op[i-1] == '/')||(op[i-1] == '%')){
				mod1 = tempData[fix];
				mod2 = tempData[i+1];
				tempData[fix] = mod1 % mod2;
			}
			else{
				mod1 = tempData[i];
				mod2 = tempData[i+1];
				tempData[i] = mod1 % mod2;
			}
		}
		else if((op[i] == '*')||(op[i] == '/')||(op[i] == '%'))
		{
			if(firstCount == 0){
				fix = i;	
				firstCount = 1;
			}
			if(op[i] == '/')
			{
				tempData[fix] = tempData[fix] / tempData[i+1];
			}
			if(op[i] == '*')
			{
				tempData[fix] = tempData[fix] * tempData[i+1];
			}
			if(op[i] == '%')
			{
				mod1 = tempData[fix];
				mod2 = tempData[i+1];
				tempData[fix] = mod1 % mod2;
			}
		}
		i++;
	}
	
	i = 0;
	sum = tempData[0];
	printf("%.1f\r\n",sum);
	while(op[i] != 0)
	{
		if(op[i] == '+')
		{
			if(i == 0){
				sum = tempData[i] + tempData[i+1];
			}
			else
			{
				sum = sum + tempData[i+1];
			}
		}
		
		if(op[i] == '-')
		{
			if(i == 0){
				sum = tempData[i] - tempData[i+1];
			}
			else
			{
				sum = sum - tempData[i+1];
			}
		}
		
		i++;
	}
	printf("%.2f",sum);
}

int main(void)
{
	char Data[32]="29%13/3-1=";
	handleData(Data);
	return 0;	
} 

